<script setup lang='ts'>
  import { onMounted, reactive } from 'vue';
  import { DailystatisticsApi } from '@/api/controller';
  import { Toastloading } from '@/utils/public';
  import { getPlayEndTime, getDateArray } from '@/utils'
  import Pagination from "@/components/Pagination/index.vue";
  const action = reactive({
    total:0,
    list:[] as any[],
    dateArr:getDateArray('year') as Array<number>,
  })
  const listQuery = reactive({
    page:1,
    limit:20,
    type:'d'
  })
  const handleSerach = ()=>{
    listQuery.page = 1
    getList()
  }
  const getList = async()=> {
    const loading = Toastloading()
    const timeObi = getPlayEndTime(action.dateArr)
    const res = await DailystatisticsApi.statisticsList({
      start_date:timeObi.playTime,
      end_date:timeObi.endTime,
      ...listQuery
    })
    loading.close()
    const { data=[], total=0 } = res.data
    action.total = total
    action.list = data
  }
  onMounted(()=>{
    getList()
  })
</script>

<template>
  <div class="xm-content">
    <div class="xm-headTab">
      <div class="labelBox">
        <div class="labelItem">
          <div class="label">日期：</div>
          <el-date-picker
            v-model="action.dateArr"
            type="daterange"
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD"
            range-separator="至"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
          />
        </div>
        <div class="labelItem">
          <div class="label">日期类型：</div>
          <el-select v-model="listQuery.type" placeholder="日期类型">
            <el-option label="日" value="d" />
            <el-option label="月" value="m" />
          </el-select>
        </div>
        <div class="labelItem">
          <el-button type="primary" @click="handleSerach">查询</el-button>
        </div>
      </div>
    </div>
    <el-table show-summary class="xm-main xm-TableCenter" :data="action.list" border>
      <el-table-column prop="pay_time" label="日期" />
      <el-table-column prop="pay_in" label="充值(单位:元)" />
      <el-table-column prop="pay_out" label="提现(单位:元)" />
      <el-table-column prop="tax" label="税后支出:(单位:元)" />
      <el-table-column prop="consumption_flow" label="消费流水:(单位:元)" />
      <el-table-column prop="recharge_ratio" label="消费充值比例" />
<!--      <el-table-column prop="settle_out" label="对公结算支出:(单位:元)" />-->
      <el-table-column prop="settle_out" label="用户剩余总量" />
    </el-table>
    <Pagination v-show="action.total > 0" :total="action.total" v-model:page="listQuery.page"
      v-model:limit="listQuery.limit" @pagination="getList" />
  </div>
</template>
